package com.nanbei.rabbit.producer.confirm;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassDescription: 生产者确认机制
 * @JdkVersion: 1.8
 * @Author: libs
 * @Created: 2024/8/30 10:47
 */
@Configuration
public class ConfirmDirectExchangeConfig {

    @Bean
    public Exchange confirmDirectExchange(){
        return ExchangeBuilder.directExchange("confirm_direct_exchange").durable(true).build();
    }

    // 队列
    @Bean
    public Queue confirmDirectQueue(){
        return QueueBuilder.durable("confirm_direct_queue")
          //      .ttl(20000)   // 为消息队列设置存活时间
                .maxLength(10L)    // 设置队列的最大存放长度
                .build();
    }

    @Bean
    public Binding confirmDirectExchange2Queue(){
        return BindingBuilder.bind(confirmDirectQueue()).to(confirmDirectExchange()).with("info").noargs();
    }
}
